// 原独立配置（保留备用）
// import axios from 'axios';
// const http = axios.create({
//   baseURL: 'http://82.157.31.31:9001',
//   timeout: 10000,
//   headers: { 'Content-Type': 'application/json' }
// });

// 使用统一配置 - 修正：使用goodsHttp实例
import { goodsHttp as http } from './config';

export interface PageInfo<T> {
  list: T[];
  total: number;
  pageNum: number;
  pageSize: number;
}

export interface GoodsCategory {
  id: number | null;
  createTime: string | null;
  updateTime: string | null;
  relaShopId: number | null;
  innerIndex: number | null;
  name: string | null;
}

// 标准接口一: 根据ID查询
export const selectById = (id: number | null) => {
  return http.get<GoodsCategory>(`/goods-category/${id}`);
};

// 标准接口二: 分页查询全部
export const selectAll = (pageNum = 1, pageSize = 10) => {
  return http.get<PageInfo<GoodsCategory>>('/goods-category', {
    params: { pageNum, pageSize }
  });
};

// 标准接口三: 新增
export const insert = (pojo: GoodsCategory) => {
  return http.post<GoodsCategory>('/goods-category', pojo);
};

// 标准接口四: 删除
export const deleteById = (id: number) => {
  return http.delete<GoodsCategory>(`/goods-category/${id}`);
};

// 标准接口五: 更新
export const update = (id: number | null, pojo: GoodsCategory) => {
  return http.put<GoodsCategory>(`/goods-category/${id}`, pojo);
};

// 标准接口六: 条件查询
export const selectEq = (conditions: Record<string, any>) => {
  return http.post<GoodsCategory[]>('/goods-category/select-eq', conditions);
};